var util = require("../../../utils/util")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    interval:'',
    currentTime:0,
    img1:'',
    img2:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  onShareAppMessage: function () {

  },
  chooseImgtap(){
    this.chooseImage()
  },
  // 选择图片
  chooseImage() {
    var that = this;
    wx.chooseImage({
      sizeType: ['original', 'compressed'], //可选择原图或压缩后的图片
      sourceType: ['camera'], //可选择性开放访问相机
      success: res => {
        that.setData({img1:res.tempFilePaths[0]})
        // 加水印
          res.tempFilePaths.forEach(function (item) {
          var watermark=that.selectComponent("#watermark")
          watermark.addMark(res.tempFilePaths[0],100 ,120, util.formatTime(new Date(),4), function (ress) {
            console.log(ress)  
            that.setData({img2:ress.tempFilePath})
          });
        })
      }
    })
  },
})